
//1.参数+注解
let outputHtml = "";
function greeter(person:string) {
    return "Hello, " + person + "</br>";
}

var user = "Jane User1";
outputHtml += greeter(user);

//2.接口，仅仅只需必要的结构形状，而不必有明确的implements子句
interface Person {
    firstName: string;
    lastName: string;
}

function hello(person: Person) {
    return "Hello, " + person.firstName + " " + person.lastName  + "</br>";
}
let user2 = { firstName: "Jane", lastName: "User2" };
outputHtml += hello(user2);

//3.class
class Student {
    fullName: string;
    //在构造函数参数中使用public是一种简写形式，它将自动创建具有该名称的属性
    constructor(public firstName, public middleInitial, public lastName) {
        this.fullName = firstName + " " + middleInitial + " " + lastName;
    }
}
let user3 = new Student("Jane", "M.", "User3");
outputHtml += hello(user3);

document.body.innerHTML =  outputHtml; 
